package com.douqu.game.core.config.map;

import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LogUtils;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-04-19 19:14
 */
public class CityArmyConfig extends GameObject {

    public int camp;

    /**
     * 1.远征
     * 2.守卫
     * 3.禁卫
     */
    public int type;

    /** 主将 */
    public int master;

    public int monsterId;

    /** 所属组 */
    public int group;
    /** 等级修正值 */
    public int lvAuxiliary;

    /**
     * 1.新手大地图
     * 2.世界大地图
     */
    public int grade;

    @Override
    public boolean setVariable(String key, String value)
    {
        if("master".equals(key))
        {
            master = Integer.parseInt(value);
            if(DataFactory.getInstance(LoadFactory.isTestLoad()).getGameObject(DataFactory.MASTER_KEY, master) == null)
            {
                LogUtils.error(getClass().getSimpleName() + " BattleInitConfig setVariable Error -> master : " + value + " id:" + id);
                return false;
            }
            return true;
        }
        else if("monsterId".equals(key))
        {
            monsterId = Integer.parseInt(value);
            if(monsterId != 0)
            {
                if(DataFactory.getInstance(LoadFactory.isTestLoad()).getGameObject(DataFactory.MONSTER_KEY, monsterId) == null)
                {
                    LogUtils.error(getClass().getSimpleName() + " BattleInitConfig setVariable Error -> monsterId : " + value + " id:" + id);
                    return false;
                }
            }
            return true;
        }
        return super.setVariable(key, value);
    }
}
